﻿using System;
using System.Collections.Generic;
using Emmajn.ChildParentExtension.SilverlightClassLibrary;
using System.Windows.Printing;

namespace Emmajn.ChildParentExtension.BusinessApplication
{
    using System.Windows.Controls;
    using System.Windows.Navigation;

    /// <summary>
    /// Home page for the application.
    /// </summary>
    public partial class Home : Page
    {
        /// <summary>
        /// Creates a new <see cref="Home"/> instance.
        /// </summary>
        public Home()
        {
            List<Inpatient> childrenList = new List<Inpatient>();
            //childrenList.Add(new Inpatient() { PatientFirstName = "George", PatientMiddleInitial = "R", PatientLastName = "Frederick", PatientSuffix = "Jr.", PatientNumber = "123-45-6789", FirstParentOrGuardianFirstLineOfHomeAddress = "123 My Street", FirstParentOrGuardianHomeCity = "My City", FirstParentOrGuardianHomeStateProvinceOrRegion = "My State", FirstParentOrGuardianHomePostalCode = "12345", FirstParentOrGuardianHomeCountry = "My Country", FirstParentOrGuardianHomeTelephoneNumber = "+001-615-555-5555", PatientLocation = "12-345", PrimaryPhysicianFirstName = "Joe", PrimaryPhysicianLastName = "Huber", PrimaryPhysicianHospitalBeeperNumber = "1221", PrimaryNurseFirstName = "Joanne", PrimaryNurseLastName = "Smith", PrimaryNurseHospitalBeeperNumber = "1234" });
            childrenList.Add(new Inpatient(new Name("George", 'R', "Frederick", "Jr."), new Number(123, 45, 6789), null, null, null, null, DateTime.Now));
            childrenList.Add(new Inpatient(new Name("James", null, "Scott", "Jr."), new Number(111, 22, 3333), null, null, null, null, DateTime.UtcNow));
            childrenList.Add(new Inpatient(new Name("Neil", 'P', "Harris", null), new Number(999, 99, 9999), null, null, null, null, DateTime.MaxValue.Date));
            childrenList.Add(new Inpatient(new Name("Tanya", null, "Harding", null), new Number(000, 00, 0000), null, null, null, null, DateTime.MaxValue.Date));

            List<Volunteer> volunteerList = new List<Volunteer>();
            //volunteerList.Add(new Volunteer(new name("Humbert", null, "Humperdink", null), new Number(987, 65, 4321), null, null, null, null, null, 1));
            volunteerList.Add(new Volunteer(new Name("William", null, "Ryker", null), new Number(999, 00, 9999)));
            volunteerList.Add(new Volunteer(new Name("Steve", 'A',"McNair", "Sr."), new Number(111, 11, 0120)));
            volunteerList.Add(new Volunteer(new Name("Kathy", null, "Bates", null), new Number(805, 48, 4856)));

            List<FamilyVisit> familyVisitList = new List<FamilyVisit>();
            ////familyVisitList.Add(new FamilyVisit(new name("James", null, "Scott", "Mr."), new VisitorNumber(111, 22, 3333), "Grandmother", DateTime.Now, DateTime.Now, 100.01, 99.99, "Saved 2 cents."));
            //////familyVisitList.Add(new FamilyVisit(new name("Mark", 'R', "Fulton", "Mr."), new VisitorNumber(123, 45, 6789), null, null, null, null, null, null));
            familyVisitList.Add(new FamilyVisit(new Name("Mark", 'R', "Fulton", "Sr."), new Number(123, 45, 6789)));
            familyVisitList.Add(new FamilyVisit(new Name("Jack", 'B', "Black", "Jr."), new Number(444, 45, 1212)));
            familyVisitList.Add(new FamilyVisit(new Name("Diana", 'L', "Ross", null), new Number(985, 15, 2394)));

            List<Report> reportList = new List<Report>();
            reportList.Add(new Report(new Number(555, 87, 6530), new Name("Ted", 'T', "Logan", null), DateTime.Now));
            reportList.Add(new Report(new Number(867, 53, 0999), new Name("Bill", 'S', "Preston", "Esq."), DateTime.Now));

            
            InitializeComponent();

          

            this.Title = ApplicationStrings.HomePageTitle;

            //populate the data grids
            childrenDataGrid.ItemsSource = childrenList;
            familyVisitsDataGrid.ItemsSource = familyVisitList;
            roleRequestDataGrid.ItemsSource = volunteerList;
            activitiesDataGrid.ItemsSource = childrenList;
            reportsDataGrid.ItemsSource = reportList;
        }   

        /// <summary>
        /// Executes when the user navigates to this page.
        /// </summary>
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
        }

        private void addChildButton_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            Views.Login.AddChildForm form = new Views.Login.AddChildForm();
            form.Show();
        }

        private void printReportsButton_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            // Create new a new PrintDocument object
            PrintDocument pd = new PrintDocument();



            // Set the printable area
            pd.PrintPage += (s, args) =>
            {
                args.PageVisual = this;
            };

            // Print the document
            pd.Print("report");
        }

        private void printActivitesButton_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            // Create new a new PrintDocument object
            PrintDocument pd = new PrintDocument();



            // Set the printable area
            pd.PrintPage += (s, args) =>
            {
                args.PageVisual = this;
            };

            // Print the document
            pd.Print("activities");
        }
       
    }
}